/********************黄涛**************************/
const {//出租方
    getLessors,
    modifyLessors,
    deleteLessors,
    EditLessors
} = require("../dao/adminsDao");
const {//车位
    getParkings,
    modifyParkings,
    deleteParkings,
    EditParkings
} = require("../dao/adminsDao");
const {//租客
    getTenants,
    modifyTenants,
    deleteTenants,
    EditTenants
} = require("../dao/adminsDao");


//出租方
module.exports.getLessors = async (req) => {
    const data = await getLessors(req);
    if (data.data.pagerows) {
        return data;
    } else {
        return {
            status: 0,
            message: "获取数据失败"
        }
    }
}
module.exports.modifyLessors = async (req) => { //单独的改变state
    const data = await modifyLessors(req);
    return data;
}

module.exports.EditLessors = async (req) => { 
    const data = await EditLessors(req);
    return data;
}
module.exports.deleteLessors = async (req) => {
    const data = await deleteLessors(req);
    return data;
}
//车位
module.exports.getParkings = async (req) => {
    const data = await getParkings(req);
    if (data.data.pagerows) {
        return data;
    } else {
        return {
            status: 0,
            message: "获取数据失败"
        }
    }
}
module.exports.modifyParkings = async (req) => { //单独的改变state
    const data = await modifyParkings(req);
    return data;
}

module.exports.EditParkings= async (req) => { 
    const data = await EditParkings(req);
    return data;
}
module.exports.deleteParkings = async (req) => {
    const data = await deleteParkings(req);
    return data;
}


//租客
module.exports.getTenants = async (req) => {
    const data = await getTenants(req);
    if (data.data.pagerows) {
        return data;
    } else {
        return {
            status: 0,
            message: "获取数据失败"
        }
    }
}
//修改认证状态
module.exports.modifyTenants = async (req) => {
    const data = await modifyTenants(req);
    return data;
}

module.exports.EditTenants = async (req) => { 
    const data = await EditTenants(req);
    return data;
}
module.exports.deleteTenants = async (req) => {
    const data = await deleteTenants();
    return data
}
/********************黄涛**************************/


/********************练超开始***********************/
const {getAdmins,deleteAdmins,forbidAdmins,addAdmins,modifyAdmins,isAdmins,seekAdmins} = require('../dao/adminsDao');

//获取管理员数据
module.exports.getAdmins = async (_id) => {
    const data =  await getAdmins(_id);
    //将普通管理员数据返回回去
    return data;

}

//删除管理员
module.exports.deleteAdmins = async (_id) => {
    const data =  await deleteAdmins(_id);
    if(data){
        return {
            message:"删除成功",
            status:1
        }
    }
    return {
        message:"删除失败",
        status:0
    };
}

//禁用管理员
module.exports.forbidAdmins = async (reqData) => {
    const data =  await forbidAdmins(reqData);
    if(data){
        return {
            message:"改变成功",
            status:1
        }
    }
    return {
        message:"改变失败",
        status:0
    };
}

//新增管理员
module.exports.addAdmins = async (reqData) => {
    const data =  await addAdmins(reqData);
    if(data._id){
        return {
            message:"新增管理员数据成功",
            status:1
        }
    }
    return {
        message:"新增管理员数据失败",
        status:0
    };
}

//修改管理员数据
module.exports.modifyAdmins = async (reqData) => {
    const data =  await modifyAdmins(reqData);
    if(data){
        return {
            message:"修改管理员数据成功",
            status:1
        }
    }
    return {
        message:"修改管理员数据失败",
        status:0
    };
}

//验证管理员账号
module.exports.isAdmins = async (reqData) => {
    const data =  await isAdmins(reqData);
    if(data.length>0){
        return {
            message:"管理员账号已存在",
            status:0
        }
    }
    return {
        message:"管理员账号合法",
        status:1
    };
}

//查找管理员
module.exports.seekAdmins = async (reqData) => {
    const data =  await seekAdmins(reqData);
    return data;
}
/********************练超结尾***********************/
